import request from './request'; // 引入统一的 Axios 实例

// 获取未归还图书
export function getCurrentUserUnReturnRecord(token) {
  return request({
    url: `/record/unreturnedbooks`,
    method: 'get',
    headers: {
      Authorization: `${token}`,
    },
  });
}

// 获取借阅记录 (新的实现)
export function getCurrentUserRecord(token) {
  return request({
    url: '/record/allbyname',
    method: 'post',
    headers: {
      Authorization: `${token}`,
    },
    // 不需要传递任何参数
  });
}

// 归还书籍
export function returnBook(bookId, token) {
  return request({
    url: '/book/returnbook',
    method: 'post',
    headers: {
      Authorization: `${token}`,
    },
    data: { bookId },  // JSON 请求体中包含 bookId
  });
}

// 删除记录
export function deleteRecordByUsername(username, token, bookId) {
  return request({
    url: `/record/delete/${username}`,
    method: 'delete',
    headers: {
      Authorization: `${token}`,
    },
    data: { bookId },  // JSON 请求体中包含 bookId
  });
}